package com.ktjy.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ktjy.pojo.clues.TbClue;
import com.ktjy.service.ITbClueService;
import com.ktjy.utils.AjaxResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 线索管理Controller
 */

@Tag(name = "线索管理模块")
@RestController
@RequestMapping("/api/clue")
public class TbClueController {
    @Autowired
    private ITbClueService tbClueService;

    /**
     * 查询线索管理列表
     */
    @Operation(summary = "线索-列表查询")
    @GetMapping("/list")
    public AjaxResult list(TbClue tbClue, @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
        IPage<TbClue> page = tbClueService.selectTbClueList(tbClue, pageNo, pageSize);
        return AjaxResult.success(page);
    }

    /**
     * 查询线索池
     *
     * @param tbClue
     * @return
     */
    @Operation(summary = "线索-查询线索池")
    @GetMapping("/pool")
    public AjaxResult pool(TbClue tbClue, @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
        IPage<TbClue> page = tbClueService.selectTbCluePool(tbClue, pageNo, pageSize);
        return AjaxResult.success(page);
    }


    /**
     * 新增线索管理
     */
    @Operation(summary = "线索-新增")
    @PostMapping
    public AjaxResult add(@RequestBody TbClue tbClue) {
        return AjaxResult.success(tbClueService.insertTbClue(tbClue));
    }

    /**
     * 修改线索管理
     */
    @Operation(summary = "线索-修改")
    @PutMapping
    public AjaxResult edit(@RequestBody TbClue tbClue) {
        return AjaxResult.success(tbClueService.updateTbClue(tbClue));
    }
}
